var app = getApp()
Page({
  data: {
    user: {},
    hasAuth: false
  },onLoad() {
    wx.setNavigationBarTitle({ title:"我的" })
    if (!app.globalData.hasUserInfo) {
      this.setData({ hasAuth: false })
    } else {
      this.setData({ hasAuth: true })
      this.setData({ user: app.globalData.userInfo })
    }
  }, getUserInfo(e) {
    if (e.detail.userInfo == null) {
      this.setData({ hasAuth: false })
    } else {
      this.setData({ hasAuth: true, user: e.detail.userInfo })
      app.globalData.userInfo = e.detail.userInfo
      app.globalData.hasUserInfo = true
      wx.cloud.callFunction({ name: 'function', data: { type: "update",table:"user",where:{openid:app.globalData.database.openId},update:{data:{userInfo:e.detail.userInfo}}}})
    }
  }
});
